<HTML><FONT FACE=Arial, Verdana, Sans><TITLE>SimulationAgent.agent</TITLE><BODY><STYLE TYPE="text/css"><!--.centeralign <BLOCKQUOTE>text-align:center</BLOCKQUOTE>--></STYLE><HEAD><P CLASS="centeralign">SimulationAgent.agent</P></HEAD><IMG SRC=images/tlabsqosmodell.SimulationAgent.png border=1 alt="Flowchart for SimulationAgent.agent" title="Flowchart for SimulationAgent.agent"></P>The package name is "tlabsqosmodell".</p>
The following external code is referenced:<BLOCKQUOTE></p>
<li>Components from java.io.*</li></p>
<li>Components from java.math.*</li></p>
<li>Components from java.util.*</li></p>
<li>Components from javax.measure.unit.*</li></p>
<li>Components from org.jscience.mathematics.number.*</li></p>
<li>Components from org.jscience.mathematics.vector.*</li></p>
<li>Components from org.jscience.physics.amount.*</li></p>
<li>Components from repast.simphony.adaptation.neural.*</li></p>
<li>Components from repast.simphony.adaptation.regression.*</li></p>
<li>Components from repast.simphony.context.*</li></p>
<li>Components from repast.simphony.context.space.continuous.*</li></p>
<li>Components from repast.simphony.context.space.gis.*</li></p>
<li>Components from repast.simphony.context.space.graph.*</li></p>
<li>Components from repast.simphony.context.space.grid.*</li></p>
<li>Components from repast.simphony.engine.environment.*</li></p>
<li>Components from repast.simphony.engine.schedule.*</li></p>
<li>Components from repast.simphony.engine.watcher.*</li></p>
<li>Components from repast.simphony.groovy.math.*</li></p>
<li>Components from repast.simphony.integration.*</li></p>
<li>Components from repast.simphony.matlab.link.*</li></p>
<li>Components from repast.simphony.query.*</li></p>
<li>Components from repast.simphony.query.space.continuous.*</li></p>
<li>Components from repast.simphony.query.space.gis.*</li></p>
<li>Components from repast.simphony.query.space.graph.*</li></p>
<li>Components from repast.simphony.query.space.grid.*</li></p>
<li>Components from repast.simphony.query.space.projection.*</li></p>
<li>Components from repast.simphony.parameter.*</li></p>
<li>Components from repast.simphony.random.*</li></p>
<li>Components from repast.simphony.space.continuous.*</li></p>
<li>Components from repast.simphony.space.gis.*</li></p>
<li>Components from repast.simphony.space.graph.*</li></p>
<li>Components from repast.simphony.space.grid.*</li></p>
<li>Components from repast.simphony.space.projection.*</li></p>
<li>Components from repast.simphony.ui.probe.*</li></p>
<li>Components from repast.simphony.util.*</li></p>
<li>Components from simphony.util.messages.*</li></p>
<li>Components from static java.lang.Math.*</li></p>
<li>Components from static repast.simphony.essentials.RepastEssentials.*</li></p>
</BLOCKQUOTE><P></p>
The class "SimulationAgent" is defined with visibility "public" which extends parent class "tlabsqosmodell.MarketEnvironment" . This is an agent.</p>
 <BLOCKQUOTE></p>
</p>
    <li>There is a field named "bestAgent" with visibility "public" of type "SimulationAgent" and default value null. This is an agent property. The block is tagged with the name "Best Agent".</li></p>
</p>
    <li>There is a field named "randomAgent" with visibility "public" of type "SimulationAgent" and default value null. This is an agent property. The block is tagged with the name "Randomly Selected Agent".</li></p>
</p>
    <li>There is a field named "rAgent" with visibility "public" of type "SimulationAgent" and default value null. This is an agent property. The block is tagged with the name "Randomly Selected Agents".</li></p>
</p>
    <li>There is a field named "reAgent" with visibility "public" of type "SimulationAgent" and default value null. This is an agent property. The block is tagged with the name "Randomly Selected Agentss".</li></p>
</p>
    <li>There is a field named "pbsConnections" with visibility "public" of type "def List" and default value new ArrayList(). This is an agent property. The block is tagged with the name "PBS Connections".</li></p>
</p>
    <li>There is a field named "nearestBackbones" with visibility "public" of type "def List" and default value new ArrayList(). This is an agent property. The block is tagged with the name "List of nearest Backbones".</li></p>
</p>
    <li>There is a field named "distance" with visibility "public" of type "double" and default value 1.0. This is an agent property. The block is tagged with the name "Distance (search for Backbones)".</li></p>
</p>
    <li>There is a field named "trafficMap" with visibility "public" of type "def" and default value null. This is an agent property. The block is tagged with the name "trafficMap".</li></p>
</p>
    <li>There is a field named "popularityagents_BE" with visibility "public" of type "def" and default value null. List with all agent popularity > 0, sorting descend The block is tagged with the name "popularityagents BE".</li></p>
</p>
    <li>There is a field named "currentCustomers" with visibility "public" of type "def" and default value "". This is an agent property. The block is tagged with the name "current Customers".</li></p>
</p>
    <li>There is a field named "totalTrafficExchange" with visibility "public" of type "def" and default value null. This is an agent property. The block is tagged with the name "total traffic exchange (A)".</li></p>
</p>
    <li>There is a field named "pathLength" with visibility "public" of type "double" and default value 0. This is an agent property. The block is tagged with the name "path length from provider to destination (l)".</li></p>
</p>
    <li>There is a field named "onPeering" with visibility "public" of type "boolean" and default value false. This is an agent property. The block is tagged with the name "Agent is in a peering decision".</li></p>
</p>
    <li>There is a field named "necessityBestAgent" with visibility "public" of type "SimulationAgent" and default value null. This is an agent property. The block is tagged with the name "Temp Agent for Peering by Necessity".</li></p>
</p>
    <li>There is a field named "trafficSources_BE" with visibility "public" of type "def" and default value null. This is an agent property. The block is tagged with the name "Traffic Sources: BE".</li></p>
</p>
    <li>There is a field named "qosTraffic" with visibility "public" of type "double" and default value 0. This is an agent property. The block is tagged with the name "QoS Traffic between 2 Agents".</li></p>
</p>
    <li>There is a field named "popularityagents_QoS" with visibility "public" of type "def" and default value null. List with all agent popularity > 0, sorting descend The block is tagged with the name "popularityagents QoS".</li></p>
</p>
    <li>There is a field named "trafficSources_QoS" with visibility "public" of type "def" and default value null. This is an agent property. The block is tagged with the name "Traffic Sources: QoS".</li></p>
</p>
    <li>There is a field named "agentsWithNoTrafficExchange" with visibility "public" of type "def List" and default value new ArrayList(). This is an agent property. The block is tagged with the name "Agents with no TrafficExchange".</li></p>
</p>
    <li>There is a field named "quaterCheck" with visibility "public" of type "int" and default value 0. property for tick/quater comparison The block is tagged with the name "check current Quater".</li></p>
</p>
    <li>There is a field named "interconnectionsThisQuater" with visibility "public" of type "def" and default value 0. Number of established Interconnections in this quater The block is tagged with the name "Number of Interconnections in this Quater".</li></p>
</p>
    </p>
    </p>
        <li>There is a method named "priceBased" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Provider Selection Method: Price-based (PR) & Price-based Selective (SEL)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "priceBased" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent.pConnections != null && randomAgent.pConnections.size() > 0) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            randomAgent.bestAgent = randomAgent.pConnections.get(0)</p>
            ArrayList tempPConnections = new ArrayList()</p>
            tempPConnections = randomAgent.pConnections - randomAgent.bestAgent</p>
</p>
             This is an agent decision.</p>
            if (tempPConnections.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                 This is a loop.</p>
                for (int i = 0; i < tempPConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    SimulationAgent tempAgent = (SimulationAgent) tempPConnections.get(i)</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.bestAgent.getTransitPriceMultiplier() > tempAgent.getTransitPriceMultiplier()) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        randomAgent.bestAgent = tempAgent</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                randomAgent.move()</p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                randomAgent.move()</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "allTrafficSourcesQoS" method has visibility     "public". This is the step behavior. The block is tagged with the name "Traffic Sources QoS".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "allTrafficSourcesQoS" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        try<BLOCKQUOTE></p>
        Context context = FindContext("TLabsQoSModell")</p>
        Network network = (Network) context.getProjection("SimulationNetwork")</p>
        Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
        def list = netQuery.query().iterator().toList()</p>
        int quater = list.get(0).quater</p>
         This is a task.</p>
        Query<SimulationAgent> netQuery3 = new PropertyGreaterThan(context,"popularity_QoS",0)</p>
        Collection temp3 = netQuery3.query().iterator().toList()</p>
        Define List of Agents predecessors in this network, to define the content sources of one agent</p>
        def popularagents_QoS = possibleConnections.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_QoS()*(-1)</p>
        </BLOCKQUOTE> </p>
         Sorted List of Agents with descending popularity</p>
        Define global popularity List , because List position ist needed to calculate t_cs !</p>
        popularityagents_QoS = temp3.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_QoS()*(-1)</p>
        </BLOCKQUOTE> </p>
         Sorted List of Agents with descending popularity</p>
        def c = 1  Fraction of client-server traffic (Now: Only CS-Traffic)</p>
        def j Rank of Content Source in CS popularity metric (populargents)</p>
        def nc_QoS = 0  Number of Traffic Sources</p>
        def alpha = 0.8 Source popularity parameter</p>
        double t_cs = 0</p>
         popularagents oder popularityagents ?</p>
        nc_QoS = popularityagents_QoS.size()</p>
        trafficSources_QoS = [:]</p>
</p>
         This is an agent decision.</p>
        if (possibleConnections != null && possibleConnections.size() >= 1 && popularityagents_QoS.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (j=0;j<popularityagents_QoS.size();j++) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def sum_k = 0</p>
</p>
                 This is a loop.</p>
                for (int i=1;i<=nc_QoS;i++) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k += 1/Math.pow(i,GetParameter("alpha"))</p>
</p>
                </BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (sum_k == null || sum_k == 0) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k = 1</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
                 This is a task.</p>
                def pos = popularityagents_QoS.indexOf(popularagents_QoS.get(j))</p>
                 round t_cs Values</p>
                t_cs = ((c*((1/Math.pow(pos+1,alpha))*i_traffic_QoS))/sum_k).round()</p>
                t_cs = ((GetParameter("c")*((1/Math.pow(pos+1,GetParameter("alpha")))*i_traffic_QoS))/sum_k)</p>
                trafficSources_QoS.put(popularagents_QoS.get(j),t_cs)</p>
</p>
            </BLOCKQUOTE></p>
</p>
             This is a task.</p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         This is a task.</p>
        </BLOCKQUOTE>catch(Exception e)<BLOCKQUOTE></p>
              println e</p>
        </BLOCKQUOTE></p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "costbenefitAnalysis" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Peering Selection Method: cost-benefit Analysis (CB)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "costbenefitAnalysis" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        System.out.println("costbenefit Analysis")</p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "necessity" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Peering Selection Method: necessity (NC)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "necessity" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null && randomAgent.transitConnections.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (int i = 0; i<randomAgent.transitConnections.size();i++) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                SimulationAgent tempAgent = (SimulationAgent) randomAgent.transitConnections.get(i)</p>
</p>
                 This is an agent decision.</p>
                if (tempAgent.transitConnections.contains(randomAgent) == true) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Projection grid = (Grid)FindProjection("TLabsQoSModell/Grid2D")</p>
                    RepastEdge removedEdge = RemoveEdge("SimulationNetwork", randomAgent, tempAgent); RepastEdge removedEdge1 = RemoveEdge("SimulationNetwork", tempAgent, randomAgent)</p>
                    RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, tempAgent, 2.0); RepastEdge createEdge1 = CreateEdge("SimulationNetwork", tempAgent, randomAgent, 2.0)</p>
                    randomAgent.transitConnections = randomAgent.transitConnections - tempAgent</p>
                    tempAgent.transitConnections = tempAgent.transitConnections - randomAgent</p>
                    randomAgent.interconnectionsThisQuater = randomAgent.interconnectionsThisQuater + 1</p>
                    tempAgent.interconnectionsThisQuater = tempAgent.interconnectionsThisQuater + 1</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.peeringConnections != null && randomAgent.peeringConnections.contains(tempAgent) == false) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        randomAgent.peeringConnections = randomAgent.peeringConnections + tempAgent</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                     This is an agent decision.</p>
                    if (tempAgent.peeringConnections != null && tempAgent.peeringConnections.contains(randomAgent) == false) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        tempAgent.peeringConnections = tempAgent.peeringConnections +randomAgent</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
                     This is a task.</p>
                    randomAgent.removeTransitLinks()</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "defineRandomAgentOLD" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "define a random Agent".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The defineRandomAgentOLD method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 4d</li></p>
        <li>interval = 2d</li></p>
        <li>priority = 1.7976931348623157E308d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "defineRandomAgentOLD" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "move" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "create an Interconnection (Edge)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "move" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (bestAgent != null && randomAgent != null && bestAgent.getConnected() == false && randomAgent.getConnected() == false && randomAgent.possibleConnections.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
             This is an agent decision.</p>
            if (randomAgent.transitConnections.contains(bestAgent) == false) <BLOCKQUOTE></p>
</p>
</p>
                 This is a loop.</p>
                for (int i = 0; i < randomAgent.possibleConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    SimulationAgent tempAgent = (SimulationAgent) randomAgent.possibleConnections.get(i)</p>
                    tempAgent.connected = true</p>
</p>
                </BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                Projection grid = (Grid)FindProjection("TLabsQoSModell/Grid2D")</p>
                RepastEdge newEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 1.0)</p>
                System.out.println("Random Agent - move: " + randomAgent)</p>
                randomAgent.transitConnections = randomAgent.transitConnections + randomAgent.bestAgent</p>
                randomAgent.interconnectionsThisQuater = randomAgent.interconnectionsThisQuater + 1</p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "removeTransitLinks" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "remove Transit Links if Agents form a Peering Link".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "removeTransitLinks" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null && randomAgent.transitConnections != null && randomAgent.transitConnections.size() > 0) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query<SimulationAgent> netQuery0 = new AndQuery(new NetworkSuccessor(network, randomAgent), new NetworkPredecessor(network, randomAgent.bestAgent))</p>
            ArrayList successor = netQuery0.query().iterator().toList()</p>
            System.out.println("RANDOM AGENT ALL AGENTS - REMOVE PEERING LINKS: " +successor +" rA/ " +randomAgent + " bA/ " +randomAgent.bestAgent)</p>
</p>
             This is an agent decision.</p>
            if (successor.size() > 0) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                successor = successor - randomAgent.peeringConnections - randomAgent.bestAgent.peeringConnections - randomAgent.qosConnections - randomAgent.bestAgent.qosConnections</p>
                System.out.println("Successor: " + successor)</p>
</p>
                 This is an agent decision.</p>
                if (successor.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                     This is a loop.</p>
                    for (int i = 0; i < successor.size(); i++) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        SimulationAgent tempAgent = (SimulationAgent) successor.get(i)</p>
                        randomAgent.transitConnections = randomAgent.transitConnections - tempAgent</p>
                        RepastEdge removedEdge = RemoveEdge("SimulationNetwork", randomAgent, tempAgent)</p>
                        randomAgent.removedAgentsBecauseOfPeering = randomAgent.removedAgentsBecauseOfPeering + tempAgent</p>
                        System.out.println("Remove TransitLInks After Last Loop: " +successor)</p>
</p>
                    </BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.bestAgent != null && randomAgent.bestAgent.transitConnections != null && randomAgent.bestAgent.transitConnections.size() > 0) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        Query<SimulationAgent> netQueryBestAgent = new AndQuery(new NetworkSuccessor(network, randomAgent.bestAgent), new NetworkPredecessor(network, randomAgent))</p>
                        ArrayList successor1 = netQueryBestAgent.query().iterator().toList()</p>
</p>
                         This is an agent decision.</p>
                        if (successor1.size() > 0) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            successor1 = successor1 - randomAgent.peeringConnections - randomAgent.bestAgent.peeringConnections - randomAgent.qosConnections - randomAgent.bestAgent.qosConnections</p>
                            System.out.println("Successor Best Agent: " + successor1)</p>
</p>
                             This is an agent decision.</p>
                            if (successor1.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                 This is a loop.</p>
                                for (int i = 0; i < successor1.size(); i++) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    SimulationAgent tempAgent = (SimulationAgent) successor1.get(i)</p>
                                    randomAgent.bestAgent.transitConnections = randomAgent.bestAgent.transitConnections - tempAgent</p>
                                    RepastEdge removedEdge = RemoveEdge("SimulationNetwork", randomAgent.bestAgent, tempAgent)</p>
                                    randomAgent.bestAgent.removedAgentsBecauseOfPeering = randomAgent.bestAgent.removedAgentsBecauseOfPeering + tempAgent</p>
                                    System.out.println("Remove TL After Last Loop Best Agent: " +successor1)</p>
</p>
                                </BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "trafficExchange" method has visibility     "public". This is the step behavior. The block is tagged with the name "traffic Exchange".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The trafficExchange method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 3d</li></p>
        <li>interval = 2d</li></p>
        <li>priority = 1.7976931348623157E308d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "trafficExchange" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        try<BLOCKQUOTE></p>
         This is a task.</p>
        Context context = FindContext("TLabsQoSModell")</p>
        Network network = (Network) context.getProjection("SimulationNetwork")</p>
        Query<SimulationAgent> netQuery = new NetworkPredecessor(context,this)       </p>
        Query<SimulationAgent> netQueryBE = new PropertyGreaterThan(context,"popularity_BE",0)</p>
        Collection temp = netQuery.query().iterator().toList()</p>
        Collection temp2 = netQueryBE.query().iterator().toList()</p>
        Define List of Agents predecessors in this network, to define the content sources of one agent</p>
        def popularagents_BE = temp.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_BE()*(-1)</p>
        </BLOCKQUOTE>  Sorted List of Agents with descending popularity</p>
        Define global popularity List , because List position ist needed to calculate t_cs !</p>
        popularityagents_BE = temp2.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_BE()*(-1)</p>
        </BLOCKQUOTE>  Sorted List of Agents with descending popularity</p>
        def c = 1  Fraction of client-server traffic (Now: Only CS-Traffic)</p>
        def j Rank of Content Source in CS popularity metric (populargents)</p>
        def nc = 0  Number of BE Traffic Sources</p>
        def alpha = 0.8 Source popularity parameter</p>
        def t_cs = 0</p>
        nc = popularagents_BE.size()</p>
        trafficMap = [:]</p>
</p>
         This is an agent decision.</p>
        if (temp != null && temp.size() >= 1) <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (j=0;j<popularagents_BE.size();j++) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def sum_k = 0</p>
</p>
                 This is a loop.</p>
                for (int i=1;i<=nc;i++) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k += 1/Math.pow(i,GetParameter("alpha"))</p>
</p>
                </BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (sum_k == null || sum_k == 0) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k = 1</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
                 This is a task.</p>
                def pos = popularityagents_BE.indexOf(popularagents_BE.get(j))</p>
                t_cs = (GetParameter("c")*((1/Math.pow(pos+1,GetParameter("alpha")))*(i_traffic)))/sum_k</p>
                trafficMap.put(popularagents_BE.get(j),t_cs)</p>
</p>
            </BLOCKQUOTE></p>
</p>
             This is a task.</p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         This is a task.</p>
        </BLOCKQUOTE>catch(Exception e)<BLOCKQUOTE></p>
              println e</p>
        </BLOCKQUOTE></p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "qosPriceBased" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "QoS Partner Selection Method: priceBased".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "qosPriceBased" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
            def list = netQuery.query().iterator().toList()</p>
            def trafficLoadsMatrix = list.get(0).trafficLoadsMatrix</p>
</p>
             This is an agent decision.</p>
            if (trafficLoadsMatrix != null) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def randomAgentColPos = matrixPos(randomAgent.toString())</p>
</p>
                 This is an agent decision.</p>
                if (randomAgentColPos != null) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Collection tempList = []</p>
                    ArrayList tempProviderArray = new ArrayList()</p>
                    tempProviderArray = []</p>
                    randomAgent.bestAgent = null</p>
                    def tempProviderColPos = 0</p>
                    def tempAgentColPos = 0</p>
                    double incomingTrafficTempProvider = 0</p>
                    double outgoingTrafficTempProvider = 0</p>
                    double trafficSum = 0</p>
</p>
                     This is a loop.</p>
                    for (int i = 0; i<randomAgent.pConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        SimulationAgent tempProvider = (SimulationAgent) randomAgent.pConnections.get(i)</p>
                        tempProviderColPos = matrixPos(tempProvider.toString())</p>
                        println "QoS SCOPE - Random Agent & Temp Provider: " +randomAgent + " ---- " +tempProvider</p>
                        incomingTrafficTempProvider = 0</p>
                        outgoingTrafficTempProvider = 0</p>
                        trafficSum = 0</p>
</p>
                         This is a loop.</p>
                        for (int j = 0; j < randomAgent.pConnections.size(); j++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent = (SimulationAgent) randomAgent.pConnections.get(j)</p>
                            tempAgentColPos = matrixPos(tempAgent.toString())</p>
                            incomingTrafficTempProvider = incomingTrafficTempProvider + trafficLoadsMatrix[tempAgentColPos][tempProviderColPos]</p>
                            outgoingTrafficTempProvider = outgoingTrafficTempProvider+ trafficLoadsMatrix[tempProviderColPos][tempAgentColPos]</p>
                            println "INCOMING AND OUTGOING TOTAL TRAFFIC: " +tempProvider + " ---- " +tempAgent + " ---- " +incomingTrafficTempProvider + " ---- " +outgoingTrafficTempProvider</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        trafficSum = incomingTrafficTempProvider + outgoingTrafficTempProvider</p>
                        println "TRAFFIC SUM: " +randomAgent + " --- " +tempProvider + " ---- " +trafficSum</p>
</p>
                         This is an agent decision.</p>
                        if (trafficSum > 0) <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                 This is an agent decision.</p>
                                if (trafficSum > tempList.max()) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.bestAgent = tempProvider</p>
                                    tempList =  [] + trafficSum</p>
                                    tempProviderArray = [] + tempProvider</p>
                                    println "QoS SCOPE - BETTER PROVIDER AGENT! " +randomAgent + " -- " +randomAgent.bestAgent</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                     This is an agent decision.</p>
                                    if (trafficSum == tempList.max()) <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        tempProviderArray = tempProviderArray + tempProvider</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                randomAgent.bestAgent = tempProvider</p>
                                tempList = tempList + trafficSum</p>
                                tempProviderArray = tempProviderArray + tempProvider </p>
                                println "QoS SCOPE - FIRST PROVIDER AGENT! " +randomAgent + " -- " +randomAgent.bestAgent</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (tempProviderArray.size() > 1) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        int number = RandomDraw(0, tempProviderArray.size())</p>
                        randomAgent.bestAgent = tempProviderArray.get(number)</p>
                        println "QoS SCOPE - BEST PROVIDER AGENT! " +randomAgent + " -- " +randomAgent.bestAgent</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.bestAgent != null && connected == false) <BLOCKQUOTE></p>
</p>
</p>
                         This is a loop.</p>
                        for (int k = 0; k < randomAgent.possibleConnections.size(); k++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent1 = (SimulationAgent) randomAgent.possibleConnections.get(k)</p>
                            tempAgent1.connected = true</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        System.out.println("QoS Direct Accessibility - selected Agent is: " +randomAgent)</p>
                        RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 3.0)</p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.qosConnections != null && randomAgent.qosConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.qosConnections = randomAgent.qosConnections + randomAgent.bestAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        println "QoS Scope - ERROR ERROR"</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "allTrafficSourcesBE" method has visibility     "public". This is the step behavior. The block is tagged with the name "start to compute I, C, T, TrafficSources_BE and TrafficSource_QoS".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The allTrafficSourcesBE method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 3d</li></p>
        <li>interval = 1d</li></p>
        <li>priority = 0.7976931348623157E308d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "allTrafficSourcesBE" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        try<BLOCKQUOTE></p>
        Context context = FindContext("TLabsQoSModell")</p>
        Network network = (Network) context.getProjection("SimulationNetwork")</p>
        Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
        def list = netQuery.query().iterator().toList()</p>
        int quater = list.get(0).quater</p>
         This is a task.</p>
        if (quater != quaterCheck) <BLOCKQUOTE></p>
        resetNumberOfInterconnections()</p>
        initTraffic()</p>
        allTrafficSourcesQoS()</p>
        setQuaterCheck(quaterCheck + 1)</p>
        Query<SimulationAgent> netQuery2 = new PropertyGreaterThan(context,"popularity_BE",0)</p>
        Collection temp2 = netQuery2.query().iterator().toList()</p>
        Define List of Agents predecessors in this network, to define the content sources of one agent</p>
        def popularagents_BE = possibleConnections.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_BE()*(-1)</p>
        </BLOCKQUOTE> </p>
         Sorted List of Agents with descending popularity</p>
        Define global popularity List , because List position ist needed to calculate t_cs !</p>
        popularityagents_BE = temp2.sort()<BLOCKQUOTE> elem -></p>
         elem.getPopularity_BE()*(-1)</p>
        </BLOCKQUOTE> </p>
         Sorted List of Agents with descending popularity</p>
        def c = 1  Fraction of client-server traffic (Now: Only CS-Traffic)</p>
        def j Rank of Content Source in CS popularity metric (populargents)</p>
        def nc_BE = 0  Number of Traffic Sources</p>
        def alpha = 0.8 Source popularity parameter</p>
        def t_cs = 0</p>
         popularagents oder popularityagents ?</p>
        nc_BE = popularityagents_BE.size()</p>
        trafficSources_BE = [:]</p>
</p>
         This is an agent decision.</p>
        if (possibleConnections != null && possibleConnections.size() >= 1 && popularityagents_BE.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (j=0;j<popularityagents_BE.size();j++) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def sum_k = 0</p>
</p>
                 This is a loop.</p>
                for (int i=1;i<=nc_BE;i++) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k += 1/Math.pow(i,GetParameter("alpha"))</p>
</p>
                </BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (sum_k == null || sum_k == 0) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    sum_k = 1</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
                 This is a task.</p>
                def pos = popularityagents_BE.indexOf(popularagents_BE.get(j))</p>
                Round t_cs Values</p>
                t_cs = ((c*((1/Math.pow(pos+1,GetParameter("alpha")))*i_traffic_BE))/sum_k).round()</p>
                t_cs = ((GetParameter("c")*((1/Math.pow(pos+1,GetParameter("alpha")))*i_traffic_BE))/sum_k)</p>
                trafficSources_BE.put(popularagents_BE.get(j),t_cs)</p>
</p>
            </BLOCKQUOTE></p>
</p>
             This is a task.</p>
            </BLOCKQUOTE> else <BLOCKQUOTE> </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         This is a task.</p>
        </BLOCKQUOTE>catch(Exception e)<BLOCKQUOTE></p>
              println e</p>
        </BLOCKQUOTE></p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "performanceBased" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Provider Selection Method: Performance-based (PF)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "performanceBased" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
            def list = netQuery.query().iterator().toList()</p>
            def providerSum = 0</p>
            double trafficTempAgentToTempProvider = 0</p>
            double pathLengthPossibleProviderToEdgeAgent = 0</p>
            def trafficEdgeToEdge = 0</p>
            def sum = 0</p>
            def trafficTempProviderToTempAgent = 0</p>
            def ssMatrixList_BE = list.get(0).ssMatrix_BE</p>
            def tempAgentColPos = 0</p>
            def tempProviderColPos = 0</p>
            def trafficCoverage = 0</p>
            Collection tempList = []</p>
            def performanceValue = 0</p>
            ArrayList tempProviderArray = new ArrayList()</p>
            tempProviderArray = []</p>
</p>
             This is an agent decision.</p>
            if (ssMatrixList_BE != null) <BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (randomAgent.typeOfNetwork == "EC") <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Query<SimulationAgent> cpQuery = new PropertyEquals(context, "typeOfNetwork", "CP")</p>
                    randomAgent.pbsConnections = cpQuery.query().iterator().toList()</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Query<SimulationAgent> ecQuery = new PropertyEquals(context, "typeOfNetwork", "EC")</p>
                    randomAgent.pbsConnections = ecQuery.query().iterator().toList()</p>
</p>
                </BLOCKQUOTE></p>
                 This is a task.</p>
                def randomAgentColPos = matrixPos(randomAgent.toString())</p>
</p>
                 This is an agent decision.</p>
                if (randomAgentColPos != null) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    randomAgent.bestAgent = null</p>
                    def pathLengthMatrixList = list.get(0).pathLengthMatrix</p>
</p>
                     This is an agent decision.</p>
                    if (pathLengthMatrixList != null) <BLOCKQUOTE></p>
</p>
</p>
                         This is a loop.</p>
                        for (int j = 0; j < randomAgent.pConnections.size(); j++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempProvider = (SimulationAgent) randomAgent.pConnections.get(j)</p>
                            tempProviderColPos = matrixPos(tempProvider.toString())</p>
                            sum = 0</p>
</p>
                             This is a loop.</p>
                            for (int i = 0; i<randomAgent.pbsConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                SimulationAgent tempAgent = (SimulationAgent) randomAgent.pbsConnections.get(i)</p>
                                tempAgentColPos = matrixPos(tempAgent.toString())</p>
                                pathLengthPossibleProviderToEdgeAgent = pathLengthMatrixList[tempAgentColPos][tempProviderColPos]</p>
</p>
                                 This is an agent decision.</p>
                                if (pathLengthPossibleProviderToEdgeAgent != Double.POSITIVE_INFINITY) <BLOCKQUOTE></p>
</p>
</p>
                                     This is an agent decision.</p>
                                    if (randomAgent.typeOfNetwork == "EC") <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        trafficTempAgentToTempProvider = ssMatrixList_BE[tempAgentColPos][tempProviderColPos]</p>
                                        trafficEdgeToEdge = ssMatrixList_BE[tempAgentColPos][randomAgentColPos]</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        trafficTempAgentToTempProvider = ssMatrixList_BE[randomAgentColPos][tempProviderColPos]</p>
                                        trafficEdgeToEdge = ssMatrixList_BE[randomAgentColPos][tempAgentColPos]</p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                     This is an agent decision.</p>
                                    if (trafficTempAgentToTempProvider < trafficEdgeToEdge) <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        trafficEdgeToEdge  = trafficTempAgentToTempProvider</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                    </BLOCKQUOTE></p>
                                     This is a task.</p>
                                    sum = sum + trafficEdgeToEdge</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.typeOfNetwork == "EC") <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                trafficCoverage = sum / randomAgent.i_traffic_BE</p>
                                println "Traffic Coverage: " +randomAgent + " ---- " +tempProvider + " ---- " +trafficCoverage</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                trafficCoverage = sum / randomAgent.c_traffic_BE</p>
                                println "Traffic Coverage: " +randomAgent + " ---- " +tempProvider + " ---- " +trafficCoverage</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                             This is an agent decision.</p>
                            if (trafficCoverage != null && trafficCoverage > 0) <BLOCKQUOTE></p>
</p>
</p>
                                 This is an agent decision.</p>
                                if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                     This is an agent decision.</p>
                                    if (trafficCoverage > tempList.max()) <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        randomAgent.bestAgent = tempProvider</p>
                                        tempList =  [] + trafficCoverage</p>
                                        tempProviderArray = [] + tempProvider</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                         This is an agent decision.</p>
                                        if (trafficCoverage == tempList.max()) <BLOCKQUOTE></p>
</p>
                                             This is a task.</p>
                                            tempProviderArray = tempProviderArray + tempProvider</p>
</p>
                                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                        </BLOCKQUOTE></p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.bestAgent = tempProvider</p>
                                    tempList = tempList + trafficCoverage</p>
                                    tempProviderArray = tempProviderArray + tempProvider </p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE></p>
</p>
</p>
                         This is an agent decision.</p>
                        if (tempProviderArray.size() > 1) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            tempList = []</p>
                            ArrayList performanceProviderArray = new ArrayList()</p>
                            performanceProviderArray = []</p>
</p>
                             This is a loop.</p>
                            for (int k = 0; k < tempProviderArray.size(); k++) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                SimulationAgent performanceTempProvider = (SimulationAgent) tempProviderArray.get(k)</p>
                                tempProviderColPos = matrixPos(performanceTempProvider.toString())</p>
                                performanceValue = 0</p>
</p>
                                 This is a loop.</p>
                                for (int p = 0; p<randomAgent.pbsConnections.size(); p++) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    SimulationAgent performanceTempAgent = (SimulationAgent) randomAgent.pbsConnections.get(p)</p>
                                    tempAgentColPos = matrixPos(performanceTempAgent.toString())</p>
                                    pathLengthPossibleProviderToEdgeAgent = pathLengthMatrixList[tempAgentColPos][tempProviderColPos]</p>
</p>
                                     This is an agent decision.</p>
                                    if (pathLengthPossibleProviderToEdgeAgent != Double.POSITIVE_INFINITY) <BLOCKQUOTE></p>
</p>
</p>
                                         This is an agent decision.</p>
                                        if (randomAgent.typeOfNetwork == "EC") <BLOCKQUOTE></p>
</p>
                                             This is a task.</p>
                                            trafficTempAgentToTempProvider = ssMatrixList_BE[tempAgentColPos][tempProviderColPos]</p>
                                            trafficEdgeToEdge = ssMatrixList_BE[tempAgentColPos][randomAgentColPos]</p>
</p>
                                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                             This is a task.</p>
                                            trafficTempAgentToTempProvider = ssMatrixList_BE[randomAgentColPos][tempProviderColPos]</p>
                                            trafficEdgeToEdge = ssMatrixList_BE[randomAgentColPos][tempAgentColPos]</p>
</p>
                                        </BLOCKQUOTE></p>
</p>
                                         This is an agent decision.</p>
                                        if (trafficTempAgentToTempProvider < trafficEdgeToEdge) <BLOCKQUOTE></p>
</p>
                                             This is a task.</p>
                                            trafficEdgeToEdge  = trafficTempAgentToTempProvider</p>
</p>
                                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                        </BLOCKQUOTE></p>
                                         This is a task.</p>
                                        performanceValue = performanceValue + pathLengthPossibleProviderToEdgeAgent trafficEdgeToEdge</p>
                                        println "Performance Value: " +randomAgent + " ---- " +performanceTempAgent + " ---- " +performanceValue</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                </BLOCKQUOTE></p>
</p>
</p>
                                 This is an agent decision.</p>
                                if (performanceValue != null && performanceValue > 0) <BLOCKQUOTE></p>
</p>
</p>
                                     This is an agent decision.</p>
                                    if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                         This is an agent decision.</p>
                                        if (performanceValue > 0 && performanceValue < tempList.min()) <BLOCKQUOTE></p>
</p>
                                             This is a task.</p>
                                            randomAgent.bestAgent = performanceTempProvider</p>
                                            tempList =  [] + performanceValue</p>
                                            performanceProviderArray = [] + performanceTempProvider</p>
</p>
                                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                             This is an agent decision.</p>
                                            if (performanceValue == tempList.min()) <BLOCKQUOTE></p>
</p>
                                                 This is a task.</p>
                                                performanceProviderArray = performanceProviderArray  + performanceTempProvider</p>
</p>
                                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                            </BLOCKQUOTE></p>
</p>
                                        </BLOCKQUOTE></p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        randomAgent.bestAgent = performanceTempProvider</p>
                                        tempList = tempList + performanceValue</p>
                                        performanceProviderArray = performanceProviderArray + performanceTempProvider </p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (performanceProviderArray.size() > 1) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                int number = RandomDraw(0, performanceProviderArray.size())</p>
                                randomAgent.bestAgent = performanceProviderArray.get(number)</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.bestAgent != null && connected == false) <BLOCKQUOTE></p>
</p>
</p>
                                 This is a loop.</p>
                                for (int i = 0; i < randomAgent.possibleConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    SimulationAgent tempAgent2 = (SimulationAgent) randomAgent.possibleConnections.get(i)</p>
                                    tempAgent2.connected = true</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 1.0)</p>
                                randomAgent.numberOfInterconnections = randomAgent.numberOfInterconnections + 1</p>
</p>
                                 This is an agent decision.</p>
                                if (randomAgent.transitConnections != null && randomAgent.transitConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.transitConnections = randomAgent.transitConnections + randomAgent.bestAgent</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.bestAgent != null && connected == false) <BLOCKQUOTE></p>
</p>
</p>
                                 This is a loop.</p>
                                for (int i = 0; i < randomAgent.possibleConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    SimulationAgent tempAgent1 = (SimulationAgent) randomAgent.possibleConnections.get(i)</p>
                                    tempAgent1.connected = true</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 1.0)</p>
                                randomAgent.numberOfInterconnections = randomAgent.numberOfInterconnections + 1</p>
</p>
                                 This is an agent decision.</p>
                                if (randomAgent.transitConnections != null && randomAgent.transitConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.transitConnections = randomAgent.transitConnections + randomAgent.bestAgent</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "checkPeeringStrategy" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Check Peering Strategy".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The checkPeeringStrategy method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 4d</li></p>
        <li>interval = 2d</li></p>
        <li>priority = -1.7976931348623157E308d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "checkPeeringStrategy" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null && randomAgent.getPeeringMethod() != null) <BLOCKQUOTE></p>
</p>
</p>
             This is an agent decision.</p>
            if (randomAgent.getPeeringMethod() == "necessity") <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                randomAgent.necessity()</p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (randomAgent.getPeeringMethod() == "trafficRatios") <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    randomAgent.trafficRatios()</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.getPeeringMethod() == "costBenefitAnalysis") <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        randomAgent.costBenefitAnalysis()</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "checkStrategy" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Check Strategy".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The checkStrategy method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 4d</li></p>
        <li>interval = 2d</li></p>
        <li>priority = 1.3976931348623157E308d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "checkStrategy" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        Context context = FindContext("TLabsQoSModell")</p>
        Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
        def list = netQuery.query().iterator().toList()</p>
        this.randomAgent = list.get(0).randomAgent</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null && randomAgent.pConnections.size() > 0 && randomAgent.interconnectionsThisQuater <= GetParameter("numberOfInterconnectionsPerQuater")) <BLOCKQUOTE></p>
</p>
</p>
             This is an agent decision.</p>
            if (randomAgent.getProviderMethod() == "priceBased") <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                priceBased()</p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                 This is an agent decision.</p>
                if (randomAgent.getProviderMethod() == "priceBasedSelective") <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    priceBasedSelective()</p>
                    priceBased()</p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.getProviderMethod() == "performanceBased") <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        performanceBased()</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.getProviderMethod() == "directAccessibility") <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            directAccessibility()</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.getProviderMethod() == "scope") <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                scope()</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            println "CHECK STRATEGY ERROR ERROR ERROR !!!"</p>
            defineRandomAgent()</p>
            println "RANDOM AGENT RANDOM Agent: " +randomAgent</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "trafficRatios" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "Peering Selection Method: traffic ratios (TR)".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "trafficRatios" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null && randomAgent.transitConnections != null && randomAgent.transitConnections.size() > 0) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
            def list = netQuery.query().iterator().toList()</p>
            def trafficLoadsMatrix = list.get(0).trafficLoadsMatrix</p>
</p>
             This is an agent decision.</p>
            if (trafficLoadsMatrix != null) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def randomAgentColPos = matrixPos(randomAgent.toString())</p>
</p>
                 This is an agent decision.</p>
                if (randomAgentColPos != null) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    randomAgent.bestAgent = null</p>
                     ArrayList tempList = new ArrayList()</p>
                     tempList = []</p>
                    def tempAgentColPos = 0</p>
                    double trafficRandomAgentToTempAgent = 0</p>
                    double trafficTempAgentToRandomAgent = 0</p>
                    randomAgent.pbsConnections = [] + randomAgent.transitConnections</p>
</p>
                     This is a loop.</p>
                    for (int i = 0; i<randomAgent.transitConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        SimulationAgent tempAgent = (SimulationAgent) randomAgent.transitConnections.get(i)</p>
                        println "RANDOM AGENT AND TEMP AGENT: " +randomAgent + " ---- " +tempAgent</p>
                        tempAgentColPos = matrixPos(tempAgent.toString())</p>
                        println "TEMP AGENT POSITION: " +tempAgentColPos</p>
                        trafficRandomAgentToTempAgent = trafficLoadsMatrix[randomAgentColPos][tempAgentColPos]</p>
                        println "TRAFFIC RANDOM AGENT TO TEMP AGENT: " +trafficRandomAgentToTempAgent</p>
                        trafficTempAgentToRandomAgent = trafficLoadsMatrix[tempAgentColPos][randomAgentColPos]</p>
                        println "TRAFFIC TEMP AGENT TO RANDOM AGENT: " +trafficTempAgentToRandomAgent</p>
                        println "QUOTIENT: " +(trafficRandomAgentToTempAgent / trafficTempAgentToRandomAgent)</p>
</p>
                         This is an agent decision.</p>
                        if (trafficRandomAgentToTempAgent > 0 && trafficTempAgentToRandomAgent > 0 && GetParameter("peeringTrafficRatio") >= (trafficRandomAgentToTempAgent / trafficTempAgentToRandomAgent) || GetParameter("peeringTrafficRatio") >= (trafficRandomAgentToTempAgent / trafficTempAgentToRandomAgent)) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.pbsConnections = randomAgent.pbsConnections - tempAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.pbsConnections.size > 0) <BLOCKQUOTE></p>
</p>
</p>
                         This is a loop.</p>
                        for (int i = 0; i<randomAgent.pbsConnections.size();i++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent1 = (SimulationAgent) randomAgent.pbsConnections.get(i)</p>
</p>
                             This is an agent decision.</p>
                            if (tempAgent1.transitConnections.contains(randomAgent) == true) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                tempList = tempList + tempAgent1</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE></p>
</p>
</p>
                         This is an agent decision.</p>
                        if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            int number = RandomDraw(0, tempList.size())</p>
                            randomAgent.bestAgent = tempList.get(number)</p>
                             This is a task.</p>
                            Projection grid = (Grid)FindProjection("TLabsQoSModell/Grid2D")</p>
                            RepastEdge removedEdge = RemoveEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent); RepastEdge removedEdge1 = RemoveEdge("SimulationNetwork", randomAgent.bestAgent, randomAgent)</p>
                            RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 2.0); RepastEdge createEdge1 = CreateEdge("SimulationNetwork", randomAgent.bestAgent, randomAgent, 2.0)</p>
                            randomAgent.transitConnections = randomAgent.transitConnections - randomAgent.bestAgent</p>
                            randomAgent.bestAgent.transitConnections = randomAgent.bestAgent.transitConnections - randomAgent</p>
                            randomAgent.interconnectionsThisQuater = randomAgent.interconnectionsThisQuater + 1</p>
                            randomAgent.bestAgent.interconnectionsThisQuater = randomAgent.bestAgent.interconnectionsThisQuater + 1</p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.peeringConnections != null && randomAgent.peeringConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                randomAgent.peeringConnections = randomAgent.peeringConnections + randomAgent.bestAgent</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.bestAgent.peeringConnections != null && randomAgent.bestAgent.peeringConnections.contains(randomAgent) == false) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                randomAgent.bestAgent.peeringConnections = randomAgent.bestAgent.peeringConnections +randomAgent</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
                             This is a task.</p>
                            System.out.println("BEST AGENT BEFORE TrafficRations: " +randomAgent.bestAgent)</p>
                            randomAgent.removeTransitLinks()</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "scope" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "QoS Partner Selection Method: scope".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "scope" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
            def list = netQuery.query().iterator().toList()</p>
            def trafficLoadsMatrix = list.get(0).trafficLoadsMatrix</p>
</p>
             This is an agent decision.</p>
            if (trafficLoadsMatrix != null) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def randomAgentColPos = matrixPos(randomAgent.toString())</p>
</p>
                 This is an agent decision.</p>
                if (randomAgentColPos != null) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Collection tempList = []</p>
                    ArrayList tempProviderArray = new ArrayList()</p>
                    tempProviderArray = []</p>
                    randomAgent.bestAgent = null</p>
                    def tempProviderColPos = 0</p>
                    def tempAgentColPos = 0</p>
                    double incomingTrafficTempProvider = 0</p>
                    double outgoingTrafficTempProvider = 0</p>
                    double trafficSum = 0</p>
</p>
                     This is a loop.</p>
                    for (int i = 0; i<randomAgent.pConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        SimulationAgent tempProvider = (SimulationAgent) randomAgent.pConnections.get(i)</p>
                        tempProviderColPos = matrixPos(tempProvider.toString())</p>
                        println "QoS SCOPE - Random Agent & Temp Provider: " +randomAgent + " ---- " +tempProvider</p>
                        incomingTrafficTempProvider = 0</p>
                        outgoingTrafficTempProvider = 0</p>
                        trafficSum = 0</p>
</p>
                         This is a loop.</p>
                        for (int j = 0; j < randomAgent.pConnections.size(); j++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent = (SimulationAgent) randomAgent.pConnections.get(j)</p>
                            tempAgentColPos = matrixPos(tempAgent.toString())</p>
                            incomingTrafficTempProvider = incomingTrafficTempProvider + trafficLoadsMatrix[tempAgentColPos][tempProviderColPos]</p>
                            outgoingTrafficTempProvider = outgoingTrafficTempProvider+ trafficLoadsMatrix[tempProviderColPos][tempAgentColPos]</p>
                            println "INCOMING AND OUTGOING TOTAL TRAFFIC: " +tempProvider + " ---- " +tempAgent + " ---- " +incomingTrafficTempProvider + " ---- " +outgoingTrafficTempProvider</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        trafficSum = incomingTrafficTempProvider + outgoingTrafficTempProvider</p>
                        println "TRAFFIC SUM: " +randomAgent + " --- " +tempProvider + " ---- " +trafficSum</p>
</p>
                         This is an agent decision.</p>
                        if (trafficSum > 0) <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                 This is an agent decision.</p>
                                if (trafficSum > tempList.max()) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.bestAgent = tempProvider</p>
                                    tempList =  [] + trafficSum</p>
                                    tempProviderArray = [] + tempProvider</p>
                                    println "QoS SCOPE - BETTER PROVIDER AGENT! " +randomAgent + " -- " +randomAgent.bestAgent</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                     This is an agent decision.</p>
                                    if (trafficSum == tempList.max()) <BLOCKQUOTE></p>
</p>
                                         This is a task.</p>
                                        tempProviderArray = tempProviderArray + tempProvider</p>
</p>
                                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                    </BLOCKQUOTE></p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                randomAgent.bestAgent = tempProvider</p>
                                tempList = tempList + trafficSum</p>
                                tempProviderArray = tempProviderArray + tempProvider </p>
                                println "QoS SCOPE - FIRST PROVIDER AGENT! " +randomAgent + " -- " +randomAgent.bestAgent</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (tempProviderArray.size() > 1) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        int number = RandomDraw(0, tempProviderArray.size())</p>
                        randomAgent.bestAgent = tempProviderArray.get(number)</p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.bestAgent != null && connected == false) <BLOCKQUOTE></p>
</p>
</p>
                         This is a loop.</p>
                        for (int k = 0; k < randomAgent.possibleConnections.size(); k++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent1 = (SimulationAgent) randomAgent.possibleConnections.get(k)</p>
                            tempAgent1.connected = true</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        System.out.println("QoS Direct Accessibility - selected Agent is: " +randomAgent)</p>
                        RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 3.0)</p>
                        RepastEdge createEdge1 = CreateEdge("SimulationNetwork", randomAgent.bestAgent, randomAgent, 3.0)</p>
                        randomAgent.interconnectionsThisQuater = randomAgent.interconnectionsThisQuater + 1</p>
                        randomAgent.bestAgent.interconnectionsThisQuater = randomAgent.bestAgent.interconnectionsThisQuater + 1</p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.qosConnections != null && randomAgent.qosConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.qosConnections = randomAgent.qosConnections + randomAgent.bestAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.bestAgent.qosConnections != null && randomAgent.bestAgent.qosConnections.contains(randomAgent) == false) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.bestAgent.qosConnections = randomAgent.bestAgent.qosConnections +randomAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "directAccessibility" method has visibility     "public" has return type "def". This is the step behavior. The block is tagged with the name "QoS Partner Selection Method: direct accesibility".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "directAccessibility" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Define the return value variable.</p>
        def returnValue</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (randomAgent != null) <BLOCKQUOTE></p>
</p>
             This is a task.</p>
            Context context = FindContext("TLabsQoSModell")</p>
            Network network = (Network) context.getProjection("SimulationNetwork")</p>
            Query netQuery = new InstanceOfQuery(context, tlabsqosmodell.SimulationMarket)</p>
            def list = netQuery.query().iterator().toList()</p>
            def ssMatrixList_QoS = list.get(0).ssMatrix_QoS</p>
</p>
             This is an agent decision.</p>
            if (ssMatrixList_QoS != null) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                def randomAgentColPos = matrixPos(randomAgent.toString())</p>
</p>
                 This is an agent decision.</p>
                if (randomAgentColPos != null) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    Collection tempList = []</p>
                    randomAgent.bestAgent = null</p>
                    def tempAgentColPos = 0</p>
                    double trafficRandomAgentToTempAgent = 0</p>
                    double trafficTempAgentToRandomAgent = 0</p>
                    double trafficExchange = 0</p>
</p>
                     This is a loop.</p>
                    for (int i = 0; i<randomAgent.pConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        SimulationAgent tempAgent = (SimulationAgent) randomAgent.pConnections.get(i)</p>
                        tempAgentColPos = matrixPos(tempAgent.toString())</p>
                        trafficRandomAgentToTempAgent = ssMatrixList_QoS[randomAgentColPos][tempAgentColPos]</p>
                        trafficTempAgentToRandomAgent = ssMatrixList_QoS[tempAgentColPos][randomAgentColPos]</p>
                        trafficExchange = trafficRandomAgentToTempAgent + trafficTempAgentToRandomAgent</p>
</p>
                         This is an agent decision.</p>
                        if (trafficExchange > 0 && tempList != null) <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (tempList.size() > 0) <BLOCKQUOTE></p>
</p>
</p>
                                 This is an agent decision.</p>
                                if (trafficExchange > tempList.max()) <BLOCKQUOTE></p>
</p>
                                     This is a task.</p>
                                    randomAgent.bestAgent = tempAgent</p>
                                    tempList =  tempList + trafficExchange</p>
</p>
                                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                                </BLOCKQUOTE></p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                randomAgent.bestAgent = tempAgent</p>
                                tempList = tempList + trafficExchange</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                             This is an agent decision.</p>
                            if (randomAgent.agentsWithNoTrafficExchange.contains(tempAgent) == false) <BLOCKQUOTE></p>
</p>
                                 This is a task.</p>
                                this.agentsWithNoTrafficExchange = this.agentsWithNoTrafficExchange + tempAgent</p>
</p>
                            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                            </BLOCKQUOTE></p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE></p>
</p>
</p>
                     This is an agent decision.</p>
                    if (randomAgent.bestAgent != null && connected == false) <BLOCKQUOTE></p>
</p>
</p>
                         This is a loop.</p>
                        for (int i = 0; i < randomAgent.possibleConnections.size(); i++) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            SimulationAgent tempAgent1 = (SimulationAgent) randomAgent.possibleConnections.get(i)</p>
                            tempAgent1.connected = true</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is a task.</p>
                        System.out.println("QoS Direct Accessibility - selected Agent is: " +randomAgent)</p>
                        RepastEdge createEdge = CreateEdge("SimulationNetwork", randomAgent, randomAgent.bestAgent, 3.0)</p>
                        RepastEdge createEdge1 = CreateEdge("SimulationNetwork", randomAgent.bestAgent, randomAgent, 3.0)</p>
                        randomAgent.interconnectionsThisQuater = randomAgent.interconnectionsThisQuater + 1</p>
                        randomAgent.bestAgent.interconnectionsThisQuater = randomAgent.bestAgent.interconnectionsThisQuater + 1</p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.qosConnections != null && randomAgent.qosConnections.contains(randomAgent.bestAgent) == false) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.qosConnections = randomAgent.qosConnections + randomAgent.bestAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                         This is an agent decision.</p>
                        if (randomAgent.bestAgent.qosConnections != null && randomAgent.bestAgent.qosConnections.contains(randomAgent) == false) <BLOCKQUOTE></p>
</p>
                             This is a task.</p>
                            randomAgent.bestAgent.qosConnections = randomAgent.bestAgent.qosConnections +randomAgent</p>
</p>
                        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                        </BLOCKQUOTE></p>
</p>
                    </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                    </BLOCKQUOTE></p>
</p>
                </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
                </BLOCKQUOTE></p>
</p>
            </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         Return the results.</p>
        return returnValue</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "resetNumberOfInterconnections" method has visibility     "public". This is the step behavior. The block is tagged with the name "reset the Agent`s number of Interconnections if a new quater starts".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The resetNumberOfInterconnections method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 1d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "resetNumberOfInterconnections" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        setInterconnectionsThisQuater(0)</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
</p>
</BLOCKQUOTE></p>
</p>
</BODY></HTML>